package com.wasion.pwportable.protocol.analyzer.terminal;

import com.wasion.pwportable.protocol.Protocol;
import com.wasion.pwportable.protocol.Result;
import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

public class NetWork_File_RD_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {
		String dataType = ackBS.substring(DATATPYESTARTBIT, DATATPYENDBIT);
		String dataLen = ackBS.substring(DATALENGTHSTARTBIT, DATALENGTHENDBIT); // 16进制的数据长度

		if (dataType.equalsIgnoreCase("F1")) {
			if (dataLen.equalsIgnoreCase("09")) {
				result.setT_NetWork_File("无信息");
			}
			if (dataLen.equalsIgnoreCase("0A")) {
				String data = ackBS.substring(DATABITSTART, DATABITSTART + 2);

				if (data.equalsIgnoreCase("00")) {
					result.setT_NetWork_File("无信息");
				}

			} else if (dataLen.equalsIgnoreCase("11")) {
				String data = ackBS.substring(DATABITSTART, DATABITSTART + 16);

				result.setT_NetWork_File(data);

				String phase = Result.phases[Integer.parseInt(data.substring(
						10, 11))];
				result.setPhase(phase);

				int groupNo = Integer.parseInt(data.substring(12, 14));
				result.setGroupNo(groupNo);

				String address = Protocol.toRealAddress(data.substring(4, 10));
				result.setiAddress(address);
			}
		} else {
			String data = "00";
			result.setT_NetWork_File(data);
		}
	}
}